#ifndef INC_POLYNOM_H_
#define INC_POLYNOM_H_


class Polynom{
	public:
		Polynom( double aA, double aB, double aC) : A(aA), B(aB), C(aC) { }
		Polynom(){}
		double A;
		double B;
		double C;
		
		bool rootsSecondDegree(SCALAR &x0, SCALAR &x1){
			SCALAR BSquare = B * B;
			SCALAR twoA = 2 * A;
			SCALAR discriminant = BSquare - 4 * A * C;

			if (discriminant < 0.0)
				return false;

			SCALAR rootDiscr = sqrt(discriminant);

			x0 = (- B - rootDiscr) / twoA;
			x1 = (- B + rootDiscr) / twoA;
			
			if(x0 > x1){//swap
				SCALAR tmpX = x0;
				x0 = x1;
				x1 = tmpX;
			}
		}

		SCALAR evaluatePolynom(SCALAR t){
			return A*t*t + B*t + C;
		}
		
		
		const Polynom operator + (const Polynom & p2){
			return Polynom(A + p2.A, B + p2.B, C + p2.C );
		}
		const Polynom operator - (const Polynom & p2){
			return Polynom(A - p2.A, B - p2.B, C - p2.C );
		}
	};

#endif